package com.openbravo.pos.reports;

import com.openbravo.basic.BasicException;
import com.openbravo.beans.JCalendarDialog;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.QBFCompareEnum;
import com.openbravo.data.loader.SerializerWrite;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class JParamsDatesInterval extends JPanel
  implements ReportEditorCreator
{
  private JButton btnDateEnd;
  private JButton btnDateStart;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JTextField jTxtEndDate;
  private JTextField jTxtStartDate;

  public JParamsDatesInterval()
  {
    initComponents();
  }

  public void setStartDate(Date paramDate)
  {
    this.jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(paramDate));
  }

  public void setEndDate(Date paramDate)
  {
    this.jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(paramDate));
  }

  public void init(AppView paramAppView)
  {
  }

  public void activate()
    throws BasicException
  {
  }

  public SerializerWrite getSerializerWrite()
  {
    return new SerializerWriteBasic(new Datas[] { Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.TIMESTAMP });
  }

  public Component getComponent()
  {
    return this;
  }

  public Object createValue()
    throws BasicException
  {
    Object localObject1 = Formats.TIMESTAMP.parseValue(this.jTxtStartDate.getText());
    Object localObject2 = Formats.TIMESTAMP.parseValue(this.jTxtEndDate.getText());
    return new Object[] { localObject1 == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_GREATEROREQUALS, localObject1, localObject2 == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_LESS, localObject2 };
  }

  private void initComponents()
  {
    this.jLabel1 = new JLabel();
    this.jTxtStartDate = new JTextField();
    this.jLabel2 = new JLabel();
    this.jTxtEndDate = new JTextField();
    this.btnDateStart = new JButton();
    this.btnDateEnd = new JButton();
    setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.bydates")));
    setPreferredSize(new Dimension(0, 100));
    setLayout(null);
    this.jLabel1.setText(AppLocal.getIntString("Label.StartDate"));
    add(this.jLabel1);
    this.jLabel1.setBounds(20, 20, 120, 15);
    add(this.jTxtStartDate);
    this.jTxtStartDate.setBounds(140, 20, 200, 19);
    this.jLabel2.setText(AppLocal.getIntString("Label.EndDate"));
    add(this.jLabel2);
    this.jLabel2.setBounds(20, 50, 120, 15);
    add(this.jTxtEndDate);
    this.jTxtEndDate.setBounds(140, 50, 200, 19);
    this.btnDateStart.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/date.png")));
    this.btnDateStart.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JParamsDatesInterval.this.btnDateStartActionPerformed(paramActionEvent);
      }
    });
    add(this.btnDateStart);
    this.btnDateStart.setBounds(350, 20, 50, 26);
    this.btnDateEnd.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/date.png")));
    this.btnDateEnd.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JParamsDatesInterval.this.btnDateEndActionPerformed(paramActionEvent);
      }
    });
    add(this.btnDateEnd);
    this.btnDateEnd.setBounds(350, 50, 50, 26);
  }

  private void btnDateStartActionPerformed(ActionEvent paramActionEvent)
  {
    Date localDate;
	try
    {
      localDate = (Date)Formats.TIMESTAMP.parseValue(this.jTxtStartDate.getText());
    }
    catch (BasicException localBasicException)
    {
      localDate = null;
    }
      localDate = JCalendarDialog.showCalendarTimeHours(this, localDate);
    if (localDate != null)
      this.jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(localDate));
  }

  private void btnDateEndActionPerformed(ActionEvent paramActionEvent)
  {
    Date localDate;
	try
    {
      localDate = (Date)Formats.TIMESTAMP.parseValue(this.jTxtEndDate.getText());
    }
    catch (BasicException localBasicException)
    {
      localDate = null;
    }
      localDate = JCalendarDialog.showCalendarTimeHours(this, localDate);
    if (localDate != null)
      this.jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(localDate));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.reports.JParamsDatesInterval
 * JD-Core Version:    0.6.0
 */